
//链式编程  流式接口
var Kitten = function(){
    this.name = "LiLi";
    this.color = "Red";
    this.gender = "Man";
};

Kitten.prototype.setName = function(name){
    this.name = name;
    return this;
};

Kitten.prototype.setColor = function(color){
    this.color = color;
    return this;
};

Kitten.prototype.setGender = function(gender){
    this.gender = gender;
    return this;
};

Kitten.prototype.save = function(){
    console.log('saving ' + this.name + ', the ' + this.color + ' ' + this.gender + ' kitten...');
    return this;
};

// use it
new Kitten()
    .setName('Bob')
    .setColor('black')
    .setGender('male')
    .save();